package org.example.service;

import org.example.model.Device;
import org.example.model.Login;

import org.example.model.Person;
import org.example.repository.LoginDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginService {
    private final LoginDao loginDao;

    @Autowired
    public LoginService(LoginDao loginDao) {
        this.loginDao = loginDao;
    }

    public Login login(String username, String password, String role) {
        return loginDao.findByLogin(username, password, role);
    }

    // 根据ID查询名字
    public String getNameById(Integer id) {
        return loginDao.getNameById(id);
    }

    // 注册用户
    public int addUser(Login login) {
        return loginDao.addUser(login);
    }

    //修改密码
    public int updatePassword(Login login) {
        return loginDao.updatePassword(login);
    }

    // 删除物料
    public void deleteUser(Integer id) {
        loginDao.deleteUser(id);
    }

} 